package com.eric.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.Nullable;

import com.gyf.barlibrary.ImmersionBar;
import com.socks.library.KLog;

/**
 * Author by jmf,
 * Date on 2021/12/7.
 */
public abstract class BaseActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        //保持屏幕常亮
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        //系统栏风格
        ImmersionBar.with(this).statusBarDarkFont(true, 0.2f).init();
        KLog.e(this.getClass().getSimpleName());

    }

    protected abstract int getLayout();

    @Override
    protected void onResume() {
        super.onResume();
        KLog.e(this.getClass().getSimpleName());
    }


    /**
     * 解决软键盘与底部输入框冲突的问题
     *
     * @param view
     */
    public void initTopBar(View view) {
        ImmersionBar.with(this).statusBarView(view)
                .keyboardEnable(true)
                .statusBarDarkFont(true, 0.2f)
                .init();
    }

    @Override
    protected void onPause() {
        super.onPause();
        KLog.e(this.getClass().getSimpleName());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        KLog.e(this.getClass().getSimpleName());
    }


    @Override
    public void finish() {
        super.finish();
        KLog.e(this.getClass().getSimpleName());
    }





}
